<template>
    <div class="goods-box" :class="direction">
        <div class="goods-icon" :style="{borderColor:getColor()}"></div>
        <div class="goods-content">
            <span class="goods-name">{{name}}</span>
        </div>
    </div>
</template>

<script>
    export default {

        name: "g-goods",
        props: {
            name : {
                type: String,
                default: ""
            },
            grade : {
                type: Number,
                default: 0
            },
            direction : {
                type: String,
                default: ""
            }
        },
        data() {
            return {
                colorArray: ["#FF34B3","#FF4040","#E066FF","#CFCFCF","#A52A2A","#43CD80"],
            }
        },
        computed: {

        },
        methods: {
            getColor(grade = this.grade % this.colorArray.length) {
                return this.colorArray[grade];
            }
        },
        created() {

        },
        mounted() {

        }
    }
</script>

<style lang="scss" scoped>

    .goods-box{
        display: flex;
        position: relative;
        /*left: 0;*/
        border: 1px #ddd solid;
        width: 150px;
        height: 60px;
        border-radius: 4px;
        margin: 3px 3px;

        cursor: default;

        &:hover{
            box-shadow: 1px 1px 3px #ddd;
        }

        .goods-icon{
            margin: 2px;
            border: 3px #ddd solid;
            height: 50px;
            width: 50px;
            cursor: pointer;
            border-radius: 5px;
        }

        .goods-content{
            width: 90px;

            .goods-name{
                display: block;
                color: gray;
                text-align: center;
                margin: 5px 0 5px 0;
            }

        }

        /*左滑进入*/
        &.left{
            animation: box-left 1s;
        }

        /*右滑进入*/
        &.right{
            animation: box-right 1s;
        }



    }

    @keyframes box-left {
        from {left: -100%;}
        to {left: 0;}
    }

    @keyframes box-right {
        from {right: -100%;}
        to {right: 0;}
    }

</style>
